package com.lq.ecoldchain.ui.mine.suggestion

import android.arch.lifecycle.MutableLiveData
import com.lq.ecoldchain.base.viewmodel.BaseViewModel
import com.lq.ecoldchain.internet.BaseObserver
import com.lq.ecoldchain.util.toast

/*
*2018/12/25 0025  15:49
*function by lq
*/
class SuggestionViewModel : BaseViewModel() {
    val edit by lazy { MutableLiveData<String>() }
    val phone by lazy { MutableLiveData<String>() }
    val content by lazy { MutableLiveData<String>() }
    val isSuccess  by lazy {   MutableLiveData<Boolean>()  }
    fun commit() {
        when (content.value.isNullOrEmpty()) {
            true -> {
                toast { "请填写内容" }
            }
            false -> {
                BaseNetCore.ApiServiceImpl.feedback(phone.value?:"", content.value!!).compose(RxTransformer.switchSchedulers()).subscribe(object:BaseObserver<String>(){
                    override fun onSuccess(t: String?) {
                        isSuccess.value = true
                    }

                    override fun onFail(code: String) {

                    }
                })
            }
        }

    }
}